package com.example.tool.adapter;

import android.content.Context;
import android.graphics.Color;
import android.opengl.Visibility;
import android.support.annotation.NonNull;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.example.tool.R;
import com.example.tool.util.DebugLog;

import java.util.HashMap;
import java.util.List;

/**
 * Created Date 2019/9/23
 *
 * @author liangkun
 * description：时间线
 */
public class TimeAxleAdapter2 extends BaseQuickAdapter<HashMap<String, Object>, BaseViewHolder> {
    private Context context;

    public TimeAxleAdapter2(Context context, List<HashMap<String, Object>> list) {
        super(R.layout.item_trace, list);
        this.context = context;
    }

    /**
     * Implement this method and use the helper to adapt the view to the given item.
     *
     * @param helper A fully initialized helper.
     * @param item   The item that needs to be displayed.
     */
    @Override
    protected void convert(@NonNull BaseViewHolder helper, HashMap<String, Object> item) {

        helper.setText(R.id.tvAcceptTime, item.get("ItemTitle").toString());
        helper.setText(R.id.tvAcceptStation, item.get("ItemText").toString());
        int adapterPosition = helper.getAdapterPosition();
        DebugLog.w("TimeAxleActivity adapterPosition " + adapterPosition + " item.get(\"ItemText\").toString() " + item.get("ItemText").toString());
        if (adapterPosition <= 6) {
            helper.setTextColor(R.id.tvAcceptTime, context.getResources().getColor(R.color.color_081029));
            helper.setTextColor(R.id.tvAcceptStation, context.getResources().getColor(R.color.color_081029));
            helper.setVisible(R.id.tvDot, adapterPosition == 6);
            helper.setBackgroundRes(R.id.tvDot, adapterPosition == 6 ? R.drawable.timelline_dot_first : R.drawable.timelline_dot_normal);
            helper.setVisible(R.id.tv_top_blue, true);
            helper.setVisible(R.id.tv_bottom_blue, true );
            helper.setBackgroundRes(R.id.tv_bottom_blue, adapterPosition == 6 ? R.color.color_gray:R.drawable.layer_dash_line);
            helper.setVisible(R.id.tv_gray, false);

        } else {
            helper.setTextColor(R.id.tvAcceptTime, context.getResources().getColor(R.color.color_4f5253));
            helper.setTextColor(R.id.tvAcceptStation, context.getResources().getColor(R.color.color_4f5253));
            helper.setVisible(R.id.tvDot, false);
            helper.setVisible(R.id.tv_top_blue, false);
            helper.setVisible(R.id.tv_bottom_blue, false);
            helper.setVisible(R.id.tv_gray, true);

        }
    }

}
